package cn.design.realize;

import java.util.List;

/**
 * @author dlq
 * @description
 *         具体容器（ConcreteAggregate）：实现容器接口定义的方法，创建出容纳迭代器的对象
 * @date 2020/10/9 13:51
 * @since 1.0
 */
public class ConcreteAggregate<T> extends Aggregate<T>{
    private T[] arr = null;

    public ConcreteAggregate(T[] arr){
        this.arr = arr;
    }
    @Override
    public  Iterator<T> iterator() {
        return new ConcreteIterator(this) ;
    }

    public int size(){
        if (arr == null ){
            return 0;
        }
        return arr.length;
    }



    @Override
    public Object get(int index) {
        return  arr[index];
    }
}
